import random
import itertools
import re


def judge(li):
    for i in itertools.permutations(li):
        for j in itertools.product(['+', '-', '*', '/'], repeat=3):
            expr = [f'(({i[0]}{j[0]}{i[1]}){j[1]}{i[2]}){j[2]}{i[3]}',
                    f'({i[0]}{j[0]}{i[1]}){j[1]}({i[2]}{j[2]}{i[3]})',
                    f'{i[0]}{j[0]}(({i[1]}{j[1]}{i[2]}){j[2]}{i[3]})',
                    f'{i[0]}{j[0]}({i[1]}{j[1]}({i[2]}{j[2]}{i[3]}))',
                    f'({i[0]}{j[0]}({i[1]}{j[1]}{i[2]})){j[2]}{i[3]}', ]
            for k in expr:
                try:
                    if eval(k) == 24:
                        return k
                except ZeroDivisionError:
                    pass
poke = sorted([str(random.randint(1, 13)) for i in range(0, 4, 1)])
print('四张扑克是：', poke)
expr = input('请输入算式：')
li = re.split('[\+\-\*\/]', expr)
if li == poke:
    if eval(expr) == 24:
        print("算式正确！")
        print('您真棒！')
    else:
        print('对不起，您输入错误！')
        print(judge(poke))
else:
    print('爪巴')
